import useActionControl from '@/hooks/useActionControl';
import SystemDictDataSelect from '@/pages/system/dictData/references/SystemDictDataSelect';
import ApiMonitorJobLog from '@/services/monitor/ApiMonitorJobLog';
import { ProTable } from '@ant-design/pro-components';

const MonitorJobLogIndex = () => {
  const actionControl = useActionControl({});

  actionControl.queryParams.refill();

  return (
    <div>
      <ProTable
        {...actionControl.table}
        request={async (params: any) => {
          const data = await ApiMonitorJobLog.list(params);

          return {
            data: data.rows,
            success: true,
            total: data.total,
          };
        }}
        rowKey={'jobLogId'}
        columns={[
          { title: '日志编号', dataIndex: 'jobLogId', hideInSearch: true },
          { title: '任务名称', dataIndex: 'jobName', ellipsis: true },
          {
            title: '任务组名',
            dataIndex: 'jobGroup',
            renderText: (_, record) => (
              <SystemDictDataSelect
                typeCode={'sys_job_group'}
                readonly={true}
                valueInLabel={false}
                value={record.jobGroup}
              />
            ),
            renderFormItem: () => (
              <SystemDictDataSelect
                typeCode={'sys_job_group'}
                valueInLabel={false}
              />
            ),
          },
          {
            title: '调用不妙字符串',
            dataIndex: 'invokeTarget',
            ellipsis: true,
            hideInSearch: true,
          },
          {
            title: '日志信息',
            dataIndex: 'jobMessage',
            ellipsis: true,
            hideInSearch: true,
          },
          {
            title: '执行状态',
            dataIndex: 'status',
            renderText: (_, record) => (
              <SystemDictDataSelect
                typeCode={'sys_common_status'}
                readonly={true}
                valueInLabel={false}
                value={record.status}
              />
            ),
            renderFormItem: () => (
              <SystemDictDataSelect
                typeCode={'sys_common_status'}
                valueInLabel={false}
              />
            ),
          },
          {
            title: '执行时间',
            dataIndex: 'createTime',
            valueType: 'dateTime',
            hideInSearch: true,
          },
        ]}
      />
    </div>
  );
};

export default MonitorJobLogIndex;
